/**
 * 
 */
package com.es.dao;


import java.util.List;

import org.apache.log4j.Logger;

import com.es.bo.LeadQualificationPropertyValueBO;
import com.es.dao.factory.SqlMapClientFactory;
import com.es.exception.dao.ESDataAccessException;
import com.es.model.LeadQualification;
import com.ibatis.sqlmap.client.SqlMapClient;


/*
 * @author Bushra Nazir
 *
 */
public class LeadQualificationDAO extends BaseDAO {

	private static final Logger log = Logger.getLogger(LeadQualificationDAO.class);




	/*
	 * @author Bushra
	 * @param Property
	 * @return List<Values>
	 * returns a list of values of a property>
	 */

	public  void saveLeadQualificationValueList(List<LeadQualification> list) throws ESDataAccessException {

		log.info(" inside saveLeadQualificationValues() "); 
		int id;

		for(int i=0; i < list.size(); i++){

			try {

				id = saveLeadQualificationValue(list.get(i));

			} catch (Exception e) {
				log.error(e);
				throw new ESDataAccessException(e);

			}


		}

	}

	public  int saveLeadQualificationValue(LeadQualification leadQualification) throws ESDataAccessException {

		log.info(" inside saveLeadQualificationValue() "); 

		SqlMapClient sqlMap =  SqlMapClientFactory.getSqlMapClient();
		int leadQualificationId = -1;

		try {
			leadQualificationId =(Integer) sqlMap.insert("leadqualification.abatorgenerated_insert", leadQualification);
			log.info("SAVED LQ ID :" + leadQualificationId);
			return leadQualificationId;
		} catch (Exception e) {
			log.error(e);
			throw new ESDataAccessException(e);

		}
	}
	
	

	public void saveLeadQualificationValues(
			List<LeadQualificationPropertyValueBO> leadQualificationPropertyValueBOList) throws  ESDataAccessException {

		log.info(" inside saveLeadQualificationValueList() --  method overriding "); 

		for (int i=0; i< leadQualificationPropertyValueBOList.size(); i++){

		 List<LeadQualification> lqList =  leadQualificationPropertyValueBOList.get(i).getLeadQualificationList();
			try{

				saveLeadQualificationValueList(lqList);

			} catch (Exception e) {
				log.error(e);
				throw new ESDataAccessException(e);

			}




		}


	}



}
